package com.wdy.po;

import java.io.Serializable;

import com.wdy.util.BasicUtil;
@SuppressWarnings({"unchecked", "serial"})
public class Building implements Serializable, Comparable {

	private Integer bid;
	private String address;
	private Float area;
	private String fitment;
	private Float perPrice;
	private Float totalPrice;
	private String sale;
	private String note;
	private Tenement tenement;
	
	public Building() {
		super();
	}

	public Building(Integer bid, String address, Float area, String fitment,
			Float perPrice, Float totalPrice, String sale, String note,
			Tenement tenement) {
		super();
		this.bid = bid;
		this.address = address;
		this.area = area;
		this.fitment = fitment;
		this.perPrice = perPrice;
		this.totalPrice = totalPrice;
		this.sale = sale;
		this.note = note;
		this.tenement = tenement;
	}

	public Integer getBid() {
		return bid;
	}

	public void setBid(Integer bid) {
		this.bid = bid;
	}

	public String getAddress() {
		return address;
	}

	public void setAddress(String address) {
		this.address = address;
	}

	public Float getArea() {
		return area;
	}

	public void setArea(Float area) {
		this.area = area;
	}

	public String getFitment() {
		return fitment;
	}

	public void setFitment(String fitment) {
		this.fitment = fitment;
	}

	public Float getPerPrice() {
		return perPrice;
	}

	public void setPerPrice(Float perPrice) {
		this.perPrice = perPrice;
	}

	public Float getTotalPrice() {
		return totalPrice;
	}

	public void setTotalPrice(Float totalPrice) {
		this.totalPrice = totalPrice;
	}

	public String getSale() {
		return sale;
	}

	public void setSale(String sale) {
		this.sale = sale;
	}

	public String getNote() {
		return note;
	}

	public void setNote(String note) {
		this.note = note;
	}

	public Tenement getTenement() {
		return tenement;
	}

	public void setTenement(Tenement tenement) {
		this.tenement = tenement;
	}
/*
	@Override
	public boolean equals(Object o) {
		if(null == o) {
			return false;
		}
		if(o instanceof Building){
			Building contrastBuilding = (Building)o;
			Integer contrastBid = contrastBuilding.getBid();
			String contrastAddress = contrastBuilding.getAddress();
			if(this.bid.equals(contrastBid) && BasicUtil.isNullOrEmpty(this.address, contrastAddress)){
				return true;
			}
		}
		return false;
	}

	@Override
	public int hashCode() {
		return this.bid.hashCode() * this.address.hashCode();
	}
*/
	@Override
	public String toString() {
		return this.address;
	}

	public int compareTo(Object o) {
		Building contrastBuilding = (Building)o;
		Integer contrastBid = contrastBuilding.getBid();
		int orignalId = this.bid.intValue();
		int contrastId = contrastBid.intValue();
		return BasicUtil.compare(orignalId, contrastId);
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((address == null) ? 0 : address.hashCode());
		result = prime * result + ((bid == null) ? 0 : bid.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (!(obj instanceof Building))
			return false;
		final Building other = (Building) obj;
		if (address == null) {
			if (other.address != null)
				return false;
		} else if (!address.equals(other.address))
			return false;
		if (bid == null) {
			if (other.bid != null)
				return false;
		} else if (!bid.equals(other.bid))
			return false;
		return true;
	}
}
